import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {MailTemplateVO, MailTemplateForm, MailTemplateQuery, SendMailForm} from '@/api/mail/template/types';

/**
 * 查询邮件模版列表
 * @param query
 * @returns {*}
 */

export const listMailTemplate = (query?: MailTemplateQuery): AxiosPromise<MailTemplateVO[]> => {
  return request({
    url: '/system/mailTemplate/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询邮件模版详细
 * @param id
 */
export const getMailTemplate = (id: string | number): AxiosPromise<MailTemplateVO> => {
  return request({
    url: '/system/mailTemplate/' + id,
    method: 'get'
  });
};

/**
 * 新增邮件模版
 * @param data
 */
export const addMailTemplate = (data: MailTemplateForm) => {
  return request({
    url: '/system/mailTemplate',
    method: 'post',
    data: data
  });
};

/**
 * 修改邮件模版
 * @param data
 */
export const updateMailTemplate = (data: MailTemplateForm) => {
  return request({
    url: '/system/mailTemplate',
    method: 'put',
    data: data
  });
};

/**
 * 删除邮件模版
 * @param id
 */
export const delMailTemplate = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/mailTemplate/' + id,
    method: 'delete'
  });
};

export const sendMail = (data: SendMailForm) => {
  return request({
    url: '/system/mailTemplate/send-mail',
    method: 'post',
    data: data
  });
};
